<?php

class Programs_Model extends ORM {

	

	protected $table_name = 'programs';

	protected $primary_key = 'programs_id';

	protected $col_sort_order = 'programs_sort_order';

	protected $col_programs_status = 'programs_status';

	protected $sorting = array('programs_id' => 'desc');

	

	public function get()

	{

		$this->db->from($this->table_name);

		$this->db->select('*');
		$this->db->where('programs_type','1');
		$this->db->orderby($this->col_sort_order,'desc');

		$this->db->orderby($this->primary_key,'desc');

		$query = $this->db->get();

		if($query->count() > 0)

			return $query->result_array(false);

		else

			return false;

	}

	

	public function get_with_active($language)

	{

		$this->db->select('*');

		$this->db->from($this->table_name);

		$this->db->join('programs_content', 'programs_content.programs_id', 'programs.programs_id');

		$this->db->where('programs_content.languages_id',$language);

		$this->db->where($this->col_programs_status,'1');
		$this->db->where('programs_type','1');
		$this->db->orderby('programs.'.$this->col_sort_order,'desc');

		$this->db->orderby('programs.'.$this->primary_key,'desc');

		$query = $this->db->get();

		return $query->result_array(false);

		

	}
	public function count_row()
	{
		$this->db->select('COUNT('.$this->primary_key.') AS max');
		$this->db->from($this->table_name);
        $this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
	public function get_oder()
	{
		$this->db->from($this->table_name);
		$this->db->select($this->primary_key);
		$this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}

}

?>